package fair.utils;

import java.util.UUID;

/**
 * Created by IntelliJ IDEA.
 * User: liuhui
 * Date: 2021/3/4 9:51
 */
public class UuidUtil {

    /**
     * 普通的uuid，36个字节
     * @return
     */
    public static String getUuid(){
        return UUID.randomUUID().toString();
    }

    /**
     * uuid，没有横杠，32个字节
     * @return
     */
    public static String getUuidWithoutHori(){
        return getUuid().replaceAll("-", "");
    }

    /**
     * 特定长度的 uuid
     * @param length
     * @return
     */
    public static String getUuid(int length){
        return getUuidWithoutHori().substring(0, length);
    }

}
